/****************************************************************************
*
*					Functions of class FeatureFactory
*
****************************************************************************/

#include <iostream>
#include "FeatureFactory.h"
#include "AllFeatureClasses.h"


/****************************************************************************
*					FeatureFactory::FeatureFactory
*
*	Description:	Standard constructor with initialization of internal parameters
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
FeatureFactory::FeatureFactory (void) {
	
}


/****************************************************************************
*					FeatureFactory::~FeatureFactory
*
*	Description:	Standard destructor with removing all dynamic internal variables
*	Parameters:		-
*	Returns:		-
*
****************************************************************************/
FeatureFactory::~FeatureFactory (void) {
	
}


/****************************************************************************
*					FeatureFactory::createObjectByID
*
*	Description:	Function creates object of ancestor class Feature
*					of a subclass with a given ID
*	Parameters:		id - identificator of subclass of class Feature
*	Returns:		Feature* - new dynamic object of subclass of 
*		  					   Feature with the given ID
*
****************************************************************************/
Feature* FeatureFactory::createObjectByID(const signed int id) {
	switch (id) { 
	case 1: 
		return new SimpleFeature();
	default: 
		std::cout << "Error in FeatureFactory::createObjectByID: no feature with id = " << id << ".\n";
	}
	Feature* feature = NULL;
	return feature;
}


/****************************************************************************
*					FeatureFactory::createObjectByName
*
*	Description:	Function creates object of ancestor class Feature
*					of a subclass with a given name
*	Parameters:		name - name of the desired subclass of class Feature
*	Returns:		Feature* - new dynamic object of subclass of 
*							   Feature with the given name
*
****************************************************************************/
Feature* FeatureFactory::createObjectByName(const std::string name) {
	Feature* feature = NULL;
	// Transforming to lowercase
	std::string nameStr (name);
	std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
	
	// Comparing the names
	if (strcmp (nameStr.c_str(), "simple") == 0) {
		return new SimpleFeature();
	}
	// Add new features here:


	// Returning the value
	return feature;
}
